﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class ContainingWord
{
    static string[] GetSentences(string text, string word)
    {
        List<string> sentences = new List<string>();
        string wordPattern = @"\b" + Regex.Escape(word) + @"\b";
        string matchPattern = @"\s*(.|\s)*[\.|\!|\?][A-Z]|\s*[A-Z]";
        Match m = Regex.Match(text, matchPattern);
        while (m.Success)
        {
            Console.WriteLine(m.Value);
            m = m.NextMatch();
        }
        //string splitPattern = @"[\.|\?|\!]\s*[A-Z]";
        //string[] sent = Regex.Split(text, splitPattern);
        //foreach (string sentence in sent)
        //{
        //    Console.WriteLine(sentence);
        //}
        return sentences.ToArray();
    }
    static void Main()
    {
        using (StreamReader reader = new StreamReader("text.txt"))
        {
            string text = reader.ReadToEnd();
            //Console.WriteLine(text);
            GetSentences(text, "a");
        }
    }
}

